package cranim.simulation;

import cranim.Constants;
import java.util.ArrayList;

/**
 *
 * @author Benedikt
 */
public class RoundResult implements Constants{
    
    private ArrayList<Shot> attackerShots;
    private ArrayList<Shot> defenderShots;
    private Player attacker;
    private Player defender;
    
    public RoundResult(int roundNum, Player attacker, Player defender){
        this.attacker = attacker;
        this.defender = defender;
        attackerShots = new ArrayList<>();
        defenderShots = new ArrayList<>();
    }
    
    public void addAttackerShot(Shot shot){
        attackerShots.add(shot);
    }
    
    public void addDefenderShot(Shot shot){
        defenderShots.add(shot);
    }
    
    public ArrayList<Shot> getAttackerShots(){
        return attackerShots;
    }
    
    public ArrayList<Shot> getDefenderShots(){
        return defenderShots;
    }

    public Player getAttacker(){
        return attacker;
    }
    
    public Player getDefender(){
        return defender;
    }
    
    public int[] getAttackerShotCount(){
        return getShots(attackerShots);
    }
    public int[] getDefenderShotCount(){
        return getShots(defenderShots);
    }
    
    private int[] getShots(ArrayList<Shot> shotlist){
        int shotcount = 0;
        int shielddmg = 0;
        int hulldmg = 0;
        for(int s = 0; s < shotlist.size(); s++){
            shotcount++;
            shielddmg += shotlist.get(s).getDmg()[SHIELD_DMG];
            hulldmg += shotlist.get(s).getDmg()[HULL_DMG];
        }
        
        int[] shots = {shotcount, shielddmg, hulldmg};
        return shots;
    }
}
